#pragma once
#include <GraphicsBaseOperation.h>
#include <MoveStrategy.h>

#define MaxAlignLine 15

class GraphicsMoveOperation :public GraphicsBaseOperation
{
public:
	GraphicsMoveOperation(GraphicsBaseItemData& itemData, QObject* parent = nullptr);

	// 图元移动
	QPointF onMoveEvent(const QPointF& newPos);

	void setMoveStrategy(std::shared_ptr<MoveStrategy> moveStrategy);
private:
	// 到父图元水平线的距离
	qreal getDistanceToParentHorizontal(const QPointF& newPos);

	// 到父图元垂直线的距离
	qreal getDistanceToParentVertical(const QPointF& newPos);

	// 到父图元中心点的距离
	qreal getDistanceToParentCenter(const QPointF& newPos);

	// 吸附
	void adsorb(const QPointF& newPos, QPointF& returnPos);
private:
	// 吸附阈值
	const int m_threshold = 20;
	std::shared_ptr<MoveStrategy> m_moveStrategy = nullptr;
};

